//
//  WelcomeViewController.swift
//  HYYWeibo
//
//  Created by HY-Mac on 16/7/15.
//  Copyright © 2016年 HY-Mac. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var iconImageView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var iconImageViewBotCons: NSLayoutConstraint!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        iconImageView.clipsToBounds = true
        iconImageView.layer.cornerRadius = 45
        assert(UserAccount.loadUserAccount() != nil, "必须授权才可以登陆")
        guard let url = NSURL(string: UserAccount.loadUserAccount()!.avatar_large!) else { return }
        iconImageView.setImageWithURL(url)
        
        
    }
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        iconImageViewBotCons.constant = view.frame.height - iconImageViewBotCons.constant
        UIView.animateWithDuration(2.0, animations: {
            self.view.layoutIfNeeded()
            
        }) { (_) in
            UIView.animateWithDuration(1.0, animations: { 
                self.nameLabel.alpha = 1.0
                }, completion: { (_) in
                 NSNotificationCenter.defaultCenter().postNotificationName(HYChangeRootViewController, object: true)
            })
           
        }
    }



}
